<template>
  <div class="toast" :class="{ show: show }" v-if="message">
    {{ message }}
  </div>
</template>

<script>
export default {
  name: 'AppToast',  // 修改组件名为多词组合
  props: {
    message: {
      type: String,
      default: ''
    },
    show: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style scoped>
.toast {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background-color: #8A69D4;
  color: white;
  padding: 10px 16px;
  border-radius: 25px;
  z-index: 1000;
  transition: transform 0.3s ease-out; /* 简化过渡效果 */
  font-size: 14px;
  box-shadow: 0 4px 15px rgba(138, 105, 212, 0.3);
  max-width: 300px;
  min-width: 100px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0; /* 添加透明度初始值 */
  pointer-events: none; /* 防止 Toast 影响其他元素的点击 */
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* 删除弹跳动画，改用简单的滑入效果 */

@media (max-width: 480px) {
  .toast {
    width: 90%;
    top: 20px;
    max-width: calc(70% - 32px);
  }
}
</style>